<?php 

/**
* 收藏控制器
*/
class AskController extends CommonController{
	private $model;
	/**
	 * [__init 构造函数]
	 * @return [type] [description]
	 */
	public function __init(){
		parent::__init();
		$this->model=K("Ask");
	}
	/**
	 * [index 首页动作]
	 * @return [type] [description]
	 */
	public function index(){
		// 显示视图
		$this->dis();
	}
	/**
	 * [add 增加动作]
	 */
	public function add(){
		if (!isset($_SESSION['uid'])) {
            echo 0;
            die();
        }
        if(!IS_POST) $this->error('非法请求',__ROOT__);
        $gid = Q('post.gid',0,'intval');
        $uid =intval($_SESSION['uid']);
        $content = Q('post.content');
       	$data = array(
        		'uid'    => $uid,
        		'gid'    => $gid,
        		'content'=>$content,
        		'uname' =>$_SESSION['u_username']
        		);
        $this->model->add_data($data);
        $data['time']=date('y-m-d');
        echo json_encode($data);
        die();
	}
	/**
	 * [del 删除动作]
	 * @return [type] [description]
	 */
	public function del(){
		$gid = Q('get.gid',0,'intval');
		$uid =intval($_SESSION['uid']);
		$this->model->delete_data("gid=$gid And uid=$uid");
		$this->success('删除成功',U('Menber/store'));
	}
	
}
















 ?>